Skip to content

Lesson 1 Review-01#1

Open
smartiqa wants to merge 7 commits intodevelopfrom
review/mgerce/RE-01
Open

Lesson 1 Review-01#1
smartiqa wants to merge 7 commits intodevelopfrom
review/mgerce/RE-01

Conversation

@smartiqa
Copy link
Contributor

@smartiqa smartiqa commented Jun 2, 2019

No description provided.

result = self.get_request(url, params, headers)
elif method is 'POST':
result = self.post_request(url, data, headers)
elif method is 'PUT':
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлена развилка для PUT и DELETE запросов. Для каждого варианта необходимо вызвать соответствующую функцию. Например, для PUT должна быть вызвана функция self.put_request(url, data, headers). На данный момент в POST, PUT и DELETE запросах почему-то всегда вызывается одна и та же функция self.post_request(url, data, headers).


def post_request(self, url, data, headers):
return requests.post(url, data=data, headers=headers)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как следствие из предыдущего коммента - зачем-то созданы 3(!) функции с одинаковым именем.

http.send_request('GET', '/get')
http.send_request('POST', '/post', data={'test_key': 'test_value'})
print(f'HTTP requests to {http.base_url} are successful!') No newline at end of file
print(f'HTTP requests to {http.base_url} are successful!')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поехала табуляция. В Python необходимо уделять особое внимание отступам, так как в данном языке они являются частью синтаксиса.

http = Http('httpbin.org', 'https')
print(f'Sending HTTP requests to {http.base_url}...')
http.send_request('GET', '/get')
http.send_request('POST', '/post', data={'test_key': 'test_value'})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отсутствуют вызовы PUT и DELETE запросов.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant